package com.jimet.security;

import com.jimet.repository.JimetRepositoryConnection;

public class JimetLoginAuthenticator {

	public JimetLoginAuthenticator() {
		super();
	}

	/**
	 * @param args
	 */

	/** Authenticates the user/passwordMD5 combination supplied.
	 * 
	 * returns the user ID
	 * @param username - the username
	 * @param passwordMD5 - MD5 hashed password, password is 
	 * not sent in clear text to prevent network sniffing
	 * @return the user ID if true, empty string if failed.
	 * @throws Exception
	 */
	public static String authenticate(String username, String passwordMD5) throws Exception
	{
		JimetRepositoryConnection repos = new JimetRepositoryConnection();
		
		String userID = repos.authenticate(username,passwordMD5);	
		if ( userID.equals("") )
		{
			userID = repos.authenticateAlt(username,passwordMD5); 
		}
		repos.disconnect();
		return userID;
	}
}
